home *** CD-ROM | disk | FTP | other *** search
/ Aminet 12 / Aminet 12 (1996)(GTI - Schatztruhe)[!][Jun 1996].iso / Aminet / dev / lang / HeliOS4.lha / helios_demo_disk4 / docs / userinterface / IncludeFiles.doc < prev    next >
Encoding:
Text File  |  1995-03-20  |  16.6 KB  |  501 lines

  1. *************
  2. Include Files
  3. *************
  4.  
  5. HeliOS V6 has an ultra-fast and flexible include symbol search facility,
  6. allowing symbolic values from Amiga include files as well as pre-defined
  7. user symbol bases to be accessed from within HeliOS programs.
  8.  
  9. HeliOS "includes" store symbolic names and associated numeric values in a
  10. special pre-encoded file format designed to allow extremely fast access.
  11.  
  12. The include files are held memory resident for fast processing.
  13.  
  14. It is very easy to generate new custom include files for any individual
  15. application, or to edit existing files: building sets of pre-processed
  16. symbols is simple and quick.
  17.  
  18. Speed of access was the main criterion when creating the HeliOS include
  19. system, since compilation speed depends heavily on the rapidity of symbol
  20. searches.  Symbol searches are VERY fast, and huge symbol bases can be
  21. conveniently accessed with virtually negligable response delay.
  22.  
  23. Without prejudice to the all-important criterion of speed, some measure
  24. of data compression has also been achieved as an additional bonus.
  25.  
  26. There is no limit on symbol base or include file size.
  27.  
  28. HeliOS can load and access two separate pre-processed include files
  29. simultaneously at any time, and a very complete set of include file
  30. functions are provided.
  31.  
  32. For example, you can:
  33.  
  34.  * Include symbolic values "transparently" in HeliOS programs.
  35.  
  36.  * Look-up and display individual symbol values from the symbol base.
  37.  
  38.  * Add individual symbols to the symbol base.
  39.  
  40.  * Delete individual symbols from the symbol base.
  41.  
  42.  * Delete a whole symbol base.
  43.  
  44.  * Display/print/save expanded ASCII format symbol listings.
  45.  
  46.  * Process symbol listing files to (re)generate new include files.
  47.  
  48.  * Use two simultaneously-on-line symbol reference include files.
  49.  
  50.  * Load either one, two or no includes files automatically at startup.
  51.  
  52.  * Load and/or change either of the two include files at any time.
  53.  
  54.  * Load and/or change either of the two include files within programs.
  55.  
  56.  * Switch on/off symbol searches from either/both of loaded includes.
  57.  
  58.  * Switch within programs between 16-bit and 32-bit include values.
  59.  
  60.  
  61. *****************************************
  62. Setting up and testing the include system
  63. *****************************************
  64.  
  65. The Interpreter window has a menu called "Includes" which contains all the
  66. include manipulation tools.
  67.  
  68. The Editor window has a few include symbol manipulation functions in the
  69. menu called "Toolkit", but all major include operations should be carried
  70. out from within the Interpreter window.
  71.  
  72. The first step is to load or create an include file to work with while you
  73. experiment with these tools.
  74.  
  75. The system may initially have no include files loaded, so try using the
  76. menu option to add a few symbols to the user include: a new user include
  77. file will automatically be created to hold your new symbols.  If you then
  78. save your new user include file, you can use this as the basis for a few
  79. simple trials to familiarise yourself with the HeliOS include system.
  80.  
  81. Once you have created your own user include file, you can tell the system
  82. how to access it and have the file loaded automatically at startup time.
  83. Otherwise you can load any include file at any time from a menu option.
  84.  
  85. See the file "InitialSetup.doc" for instructions on how to set up startup
  86. default include files.
  87.  
  88. An include file containing Amiga OS symbolic values is provided ready for
  89. use: you might wish to use the "Include" menu options in the Interpreter
  90. window to load this file as the current Amiga include file.
  91.  
  92. You can also tell the HeliOS system to autoload this file as the default
  93. Amiga include file if you like: if you do this you will in future always 
  94. have all the Amiga include symbols "on-line".
  95.  
  96. Note that each time you add a symbol to the user include, the system has
  97. to insert this new symbol into the existing list and sort the list.  With
  98. a small include file this process is instantaneous, but if you try adding
  99. new symbols to the large Amiga include file there will be a slight delay
  100. while the list is re-sorted.
  101.  
  102. To try out the HeliOS include system at its simplest level, try using the
  103. menu option to add a few new user symbols: note that you can use "$" and 
  104. "%"" for hex and binary numbers, or no prefix for decimal numbers.
  105.  
  106. You can now use the menu option to get the values of any of your symbols.
  107.  
  108. Your new symbol names can also be entered at the command line or in your
  109. program source code. The HeliOS interpreter will recognise a symbolic name
  110. and translate it into a (double) 32-bit number or (normal) 16-bit number,
  111. depending on the use of the words LONGINCLUDE and WORDINCLUDE for the 
  112. purposes of program compilation and execution.
  113.  
  114. By default, at startup, each of the include symbols is translated as a 
  115. 32-bit number as far as the HeliOS interpreter is concerned.
  116.  
  117. The word WORDINCLUDE switches over to 16-bit include translation, which
  118. will remain in force until you use the word LONGINCLUDE or you restart
  119. the system.
  120.  
  121. Try making a new symbol called MYSYMBOL, giving it the value 10.
  122.  
  123. Now try typing "MYNEWSYMBOL .S" at the command line.
  124.  
  125. You will notice that the 32-bit number 10. is now on the stack, just as if
  126. you had origianlly typed "10. .S" rather than "MYNEWSYMBOL .S".
  127.  
  128. Type "SP!" to clear the stack.
  129.  
  130. Now try typing "WORDINCLUDE" at the command line, followed by the previous
  131. "MYNEWSYMBOL .S".
  132.  
  133. You will notice that a 16-bit number 10 is now on the stack, just as if
  134. you had origianlly typed "10 .S" rather than "MYNEWSYMBOL .S".
  135.  
  136.  
  137. *********
  138. Important
  139. *********
  140.  
  141.  1. Include symbols are case sensitive, unlike HeliOS words, so take care.
  142.  
  143.  2. Include symbols are ALWAYS translated into 32-bit numbers or 16-bit
  144.     numbers according to the use of WORDINCLUDE and LONGINCLUDE.
  145.  
  146.     Remember that the default is 32-bit, and make sure that your software
  147.     clearly and explicitly sets include symbol length correctly before
  148.     using include symbolic values.
  149.  
  150.  3. Although include symbols may be translated into DOUBLE 32-bit numbers,
  151.     you do NOT (and MUST NOT) use a "." to signify a double number when
  152.     entering a symbol value when defining a symbol.
  153.  
  154.     This is NOT like entering a number in HeliOS code - just enter the
  155.     numeric value with no ".".
  156.  
  157.  
  158. *****************
  159. How includes work
  160. *****************
  161.  
  162. As mentioned above, there is the facility to manage two include files on-
  163. line at any one time, and these two files have slightly different useage.
  164.  
  165.  
  166. *********************************
  167. 1st include file = "User include"
  168. *********************************
  169.  
  170. This file is intended to to be a flexible and easily configurable resource
  171. for symbolic values you wish to create for individual programs.
  172.  
  173. You can easily:
  174.  
  175.  * Add a new symbol
  176.  * Remove any symbol
  177.  * View symbol values
  178.  * Create a current listing
  179.  * Load a new file
  180.  * Save the current file
  181.  * Switch on/off startup autoload
  182.  * Set startup autoload default file
  183.  * Choose whether or not this include file will be used in symbol searches
  184.  * Close down the include file and free memory resources
  185.  
  186.  
  187. **********************************
  188. 2nd include file = "Amiga include"
  189. **********************************
  190.  
  191. This file is intended to to be a relatively fixed "large" symbol resource
  192. like the CBM include files.  We call this the "Amiga" include because it
  193. is intended to store all the Amiga OS include symbolic values.
  194.  
  195. You can:
  196.  
  197.  * View symbol values
  198.  * Load a new file
  199.  * Switch on/off startup autoload
  200.  * Set startup autoload default file
  201.  * Choose whether or not this include file will be used in symbol searches
  202.  
  203.  
  204. ***********
  205. File format
  206. ***********
  207.  
  208. Both "User" and "Amiga" include files have identical file formats.
  209.  
  210. This means that you can:
  211.  
  212.  * Load any HeliOS include file in either status.
  213.  
  214.  * Operate on any include file with the more powerful "User" include tools.
  215.    e.g. You can change individual symbols in the file you usually use as
  216.         the "Amiga" include by first loading it in as the "User" include.
  217.  
  218. Although the file format is "encoded", you have a wide range of facilities
  219. for editing HeliOS include files.
  220.  
  221. You can use the "Display current user include" function to generate an
  222. ASCII listing of an include file so that you can see just what symbols are
  223. in there.  This listing can be passed into the "OUT" editor.
  224.  
  225. This ASCII listing can be freely edited and then "recompiled" into a new
  226. HeliOS include file using the "Convert equ file to include" function.
  227.  
  228. You can also edit individual symbols directly "on-line" and re-save the
  229. edited include file.
  230.  
  231. This gives you a virtually unlimited scope for creating/editing include
  232. symbol bases.  You can either generate a new include file from an ASCII
  233. listing, or simply create new symbols individually as you go.
  234.  
  235.  
  236. ************************************
  237. Converting ASCII to "HeliOS Include"
  238. ************************************
  239.  
  240. The "Convert equ file to include" function allows you to process any ASCII
  241. "equate" listing into a HeliOS include file.
  242.  
  243. The ASCII file parser is very flexible, but there obviously must be some
  244. constraints.
  245.  
  246. The ASCII listing must be in the following format:
  247.  
  248.  1. Each line must start with the first letter of the symbol name
  249.  2. Each line must end with the numeric symbol value
  250.  3. Hex values must be prefixed by "$"
  251.  4. Binary values must be prefixed by "%"
  252.  5. All other values will be treated as decimal
  253.  6. Negative values should have "$" or "%" identifier BEFORE the "-" sign
  254.  
  255. These are all valid lines:
  256.  
  257. MYSYMBOL equ $0000001
  258. MYSYMBOL $0000001
  259. MYSYMBOL                           %100100
  260. MYSYMBOL EQUALS     157
  261. MYSYMBOL any old thing can go in here if you like $12
  262. MYSYMBOL 3
  263. MYSYMBOL equ    $-C
  264.  
  265. The important thing is that the first and last items are the symbol and
  266. the numeric value.
  267.  
  268. You can use this conversion facility to import "equ" files from other
  269. sources and include these "foreign" symbols in HeliOS code.
  270.  
  271. Remember that all include symbols are always case sensitive.
  272.  
  273.  
  274. ************************************
  275. Interpretation and search precedence
  276. ************************************
  277.  
  278. If you want to make best use of the software for fast compilation it helps
  279. to know what is happening internally.
  280.  
  281. Always remember that using symbolic values from the include files will
  282. slow down program compilation to some small extent.  Here is why:
  283.  
  284. The interpreter carries out searches in the following order as it parses
  285. the input stream:
  286.  
  287.   1. It gets the next space-delimited ASCII word from the input stream
  288.  
  289.   2. It searches the HeliOS vocabulary for a matching word
  290.  
  291. .....if this fails
  292.  
  293.   3. It tries to interpret the word as a number using the current base
  294.  
  295. .....if this fails
  296.  
  297.   4. It tries to find the word in the "User" include file only if
  298.  
  299.       a. If there is a "User" include loaded
  300.       b. If the "User" include search function is switched on
  301.  
  302. .....if this fails
  303.  
  304.   5. It tries to find the word in the "Amiga" include file only if
  305.  
  306.       a. If there is an "Amiga" include loaded
  307.       b. If the "Amiga" include search function is switched on
  308.  
  309. .....if all these fail you have an error!
  310.  
  311.  
  312. This means that:
  313.  
  314.  1. A HeliOS constant with the same mame as an include symbol will take
  315.     precedence and will be accepted first and fastest by the interpreter.
  316.  
  317.  2. A "User include" symbol with the same mame as an "Amiga include" symbol
  318.     will take precedence and will be accepted first by the interpreter.
  319.  
  320.  
  321. **********************************************
  322. Pros and cons of various numeric entry methods
  323. **********************************************
  324.  
  325. You can enter numbers:
  326.  
  327.  1. As coded HeliOS constants (or variables)
  328.  2. As include file symbols
  329.  3. Directly as numbers
  330.  
  331. Note that:
  332.  
  333. *****************************************
  334. Coded "Constants" are fastest.....but....
  335. *****************************************
  336.  
  337. The fastest compilation will always result from storing numeric values as
  338. coded HeliOS constants.
  339.  
  340. This method has these advantages:
  341.  
  342.  1. It is fastest
  343.  
  344.  2. It uses less dictionary space in HeliOS (unlike traditional Forth)
  345.  
  346.  3. You can access numbers by convenient and less error prone symbolic names
  347.  
  348.  4. You can use 8-bit, 16-bit or 32-bit values
  349.  
  350.  5. Source code is more comprehensible using symbols
  351.  
  352.  6. Global symbol changes are easy and convenient
  353.  
  354.  7. Symbols created in this way are not case sensitive
  355.  
  356. It also has these disadvantages:
  357.  
  358.  1. It is more involved to set up
  359.  
  360.  2. It is not "realistic" to access all the CBM include symbols in this way!
  361.  
  362.  3. It is less flexible.
  363.  
  364.  4. Symbols are less easily portable between programs.
  365.  
  366.  5. Importing symbol bases from other sources is difficult/inconvenient
  367.  
  368.  6. These symbols names not being case sensitive may actually be a problem
  369.  
  370.  
  371. ***************************************************
  372. Hard-coded "Numbers" are nearly as fast.....but....
  373. ***************************************************
  374.  
  375. Using a "hard coded" number is nearly as good in terms of speed but can be
  376. tedious and can tend to introduce errors.
  377.  
  378. In fact HeliOS provides an include symbol "look-up" facility so that you
  379. can easily get numeric values for include symbols if you want to enter
  380. a numeric value directly.
  381.  
  382. This method has these advantages:
  383.  
  384.  1. It is fast
  385.  
  386.  2. It is easy when experimenting with code development
  387.  
  388.  3. You do not need to remember symbol names
  389.  
  390.  
  391. It also has these disadvantages:
  392.  
  393.  1. It can be rather error prone
  394.  
  395.  2. Translating values from external symbolic sources is tedious
  396.  
  397.  3. Source code is less comprehensible
  398.  
  399.  4. Global symbol changes are difficult
  400.  
  401.  
  402. ****************************************************
  403. Include symbols may not be quite so fast.....but....
  404. ****************************************************
  405.  
  406. Using includes is very convenient and flexible, allows easy portability of
  407. symbols between programs (and even from other programming environments),
  408. and has good error protection since symbols are precise and case sensitive.
  409.  
  410.  
  411. This method has these advantages:
  412.  
  413.  1. It is fast enough for most purposes
  414.  
  415.  2. You can access numbers by convenient and less error prone symbolic names
  416.  
  417.  3. Source code is more comprehensible using symbols
  418.  
  419.  4. Symbol bases can easily be imported/exported
  420.  
  421.  5. All symbols can be easily output as an alphabetic listing
  422.  
  423.  6. Global symbol changes are easy
  424.  
  425.  7. Case sensitivity is enforced, which may be helpful
  426.  
  427. It also has these disadvantages:
  428.  
  429.  1. It has the slowest compilation of the methods under discussion
  430.  
  431.  2. Symbols and source code are not fully integrated
  432.  
  433.  3. All symbols are translated only as 32-bit or 16-bit numbers
  434.  
  435.  4. Case sensitivity is enforced, which may be a nuisance
  436.  
  437.  5. Careless use of WORDINCLUDE and LONGINCLUDE can cause problems
  438.  
  439. Although we have said they are the slowest option, for general use the
  440. include symbol searches are quite sufficiently quick.
  441.  
  442. You may choose to employ include file symbols for the majority of cases
  443. where speed of compilation is not absolutely vital.
  444.  
  445. Include files are certainly the most flexible method of accessing numeric
  446. and symbolic values provided that:
  447.  
  448.  a. The small compilation speed penalty is tolerable
  449.  
  450.  b. The enforced 32-bit or 16-bit number translation is appropriate
  451.  
  452.  c. You take care to use WORDINCLUDE and LONGINCLUDE carefully
  453.  
  454. ****************************
  455. Compilation versus execution
  456. ****************************
  457.  
  458. It may be pointed out that the above speed considerations only relate to
  459. the process of interpretation and compilation of the dictionary.
  460.  
  461. This means that the final program will run at the same speed whatever
  462. method you use.
  463.  
  464. See the file "HeliOSCompilation.doc" for a detailed discussion of how
  465. the compilation process works, and the pros and cons of the various ways
  466. of using symbolic values.
  467.  
  468.  
  469. *****************************************************************
  470. Overview of the effects of using "include" versus "coded" symbols
  471. *****************************************************************
  472.  
  473. The initial processes of interpretation and compilation will be affected
  474. to some extent by the methods of symbol definition which you employ.
  475.  
  476. Compilation will be fastest when using HeliOS constants for symbolic values,
  477. and the symbol names will be stored in the HeliOS vocabulary list.
  478.  
  479. HeliOS coded constants may be conveniently defined as 8-bit, 16-bit or
  480. 32-bit values.
  481.  
  482. Include symbol searches will slightly increase compilation times, but you
  483. may well find any compilation speed differences insignificant on most
  484. programs since the HeliOS compiler is very quick anyway.
  485.  
  486. Include symbols are translated into pure 32-bit or 16-bit numbers during
  487. the process of compilation, so they do not affect the HeliOS vocabulary
  488. at all.
  489.  
  490. Include symbols are translated during the process of compilation, so the
  491. include file plays no part in program execution and is not needed after
  492. program compilation.
  493.  
  494. Include symbols are all translated automatically as 32-bit or 16-bit
  495. numbers depending on the use of WORDINCLUDE and LONGINCLUDE.
  496.  
  497. Final program execution will be totally unaffected by methods of symbol
  498. definition.
  499.  
  500. *****************************************************************************
  501.